package com.qingyang.activemq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * 消费者
 *
 * @author Administrator
 * Created on 2017/12/1
 */
public class TestQueueMsgListen implements MessageListener {
    private static Logger log = LoggerFactory.getLogger(Producter.class);

    @Override
    public void onMessage(Message message) {
        if (message instanceof TextMessage) {
            TextMessage textMessage = (TextMessage) message;
            String parameStr = "";

            try {
                System.out.println("receive message: " + textMessage.getText());
            } catch (JMSException e) {
                e.printStackTrace();
            } catch (RuntimeException e) {
                System.out.println("消费---消息处理失败: " + parameStr);
            }
        }
    }
}
